<template>
  <div class="news_item" @click="goDetail">
    <header>
      {{ data.conTitle }}
    </header>
    <footer>
      <div class="left">
        <img v-if="src" :src="src" style="width: 15px;height: 15px;vertical-align: middle;" alt="">
        <div>{{ data.conAuthor
        }}</div>
      </div>
      <div class="right">{{ data.pubTime.split(' ')[0] }}</div>
    </footer>
  </div>
</template>

<script setup lang='ts'>
import { INewsRes } from '@/pages/importantNews/type';
import router from '@/router';
import { PropType, ref } from 'vue';
const props = defineProps({
  src: {
    type: String,
    default: ''
  },
  data: {
    type: Object as PropType<INewsRes>,
    default: () => ({})
  }
})
function goDetail() {
  router.push('/news-detail/' + props.data.id)
  if (props.data.linkType == '1') {
    //内部
    router.push('/news-detail/' + props.data.id)
  } else if (props.data.linkType == '2') {
    window.location.href = props.data.linkAddress as string
  }
}
</script>

<style scoped lang="less">
.news_item {
  border-bottom: 1px solid #EBEDEF;
  padding: 10px 0;

  header {
    text-align: left;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #0D1722;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  footer {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-family: PingFangSC-Regular, PingFang SC;
    color: #8590A5;
    margin-top: 10px;

    .left {
      display: flex;
      align-items: center;

      &>div {
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;

      }

      img {
        margin-right: 5px;
      }
    }
  }
}
</style>